import React, { useState, useEffect } from 'react';
const { BMapGL, BMap } = window;
// @ts-ignore
function BaiMap(props: any) {
  const { setParent } = props;
  useEffect(() => {
    renderMap();
  }, []);
  const renderMap = () => {
    const map = new BMap.Map('container', {
      coordsType: 5,
    });
    map.centerAndZoom(new BMap.Point(116.404, 39.928), 15);
    map.enableScrollWheelZoom(true);
    map.addEventListener('click', function (e: any) {
      const { lat, lng } = e.target.he;
      let a = JSON.stringify({ x: lat, y: lng });
      //console.log(a)
      setParent(a);
    });
  };
  return (
    <div
      id="container"
      style={{
        overflow: 'hidden',
        width: '100%',
        height: '100%',
        margin: '0',
        fontFamily: '微软雅黑',
      }}
    >
      {' '}
    </div>
  );
}
// @ts-ignore
export default BaiMap;
